{extend name="platform/base" /}
{block name="resources"/}
<style>
.modal-infp-style{width:100%;margin:10px auto;}
.modal-infp-style table{width:100%;}
.modal-infp-style table tr td{border: 1px solid #e5e5e5;padding: 10px;}
.ns-main{margin-top: 0;}
.img-container{    height: 90px;line-height: 90px; width: 90px;text-align: center;margin-left: 0 !important;display: inline-block;}
.img-container,.img-mid  img{display: inline-block !important;vertical-align: middle !important;max-width: 100% !important;max-height: 100% !important;height: auto !important;}
.img-mid{height: 120px;line-height: 120px; width: 120px;text-align: center;margin-left: 0 !important;display: inline-block;}

.fa {display: grid;}
.text-active, .active>.text {display: none;}
.searchable-select-item.selected ,.searchable-select-item.hover {background: #65bd77!important;}
.searchable-select{line-height: 1.2!important; border-color: #d9d9d9!important;}
.searchable-select-dropdown{border: 1px solid #d9d9d9 !important;}
.searchable-select-holder{
	border: 1px solid #d9d9d9 !important;
	-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0) !important;;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0) !important;;
    -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}
.searchable-select-holder{border-radius: 2px!important;}

</style>
{/block}
 {block name="main"}
<div class="row padder-v">
	<div class="col-sm-1">
	<a href="javascript:;" class="btn btn-sm btn-primary" onclick="batchDelete();" ><i class="fa"></i> 批量删除</a>
	</div>
	<div class="col-sm-2">
	<a href="{:__URL('PLATFORM_MAIN/config/addRoutingRules')}" class="btn btn-sm btn-primary"  ><i class="fa"></i> 添加路由</a>
	</div>

</div>
<section class="panel panel-default">
		<table class="table table-striped b-light text-sm">
			<colgroup>
				<col style="width: 2%;">
				<col style="width: 10%;">
				<col style="width: 15%;">
				<col style="width: 15%;">
				<col style="width: 15%;">
				<col style="width: 10%;">
				<col style="width: 10%;">
				<col style="width: 10%;">
			</colgroup>
			<thead>
				<tr align="center">
					<th></th>
					<th align="left">类型</th>
					<th align="left">标题</th>
					<th align="left">接收账号</th>
					<th>简介</th>
					<th>状态</th>
					<th>操作</th>
					
				</tr>
			</thead>
			<tbody  id="list">
				
			</tbody>
		</table>
	

	{include file="platform/page" /}
</section>
{/block} 
{block name="script"}
<link rel="stylesheet" type="text/css" href="__ROOT__/public/admin/css/plugin/jquery.searchableSelect.css">
<script src="__ROOT__/public/admin/js/plugin/jquery.searchableSelect.js"></script>
<script src="__STATIC__/js/BootstrapMenu.min.js"></script>

<script type="text/javascript">

$(function(){
	LoadingInfo(1);
});





function LoadingInfo(page_index) {
	$.ajax({
		type : "post",
		url : "{:__URL('PLATFORM_MAIN/config/customPseudoStaticRule')}",
		data : 
		{
			"page_index" : page_index, 
			"page_size" : $("#showNumber").val()
		},
		success : function(data) {
			if(data["data"].length > 0){
				$("#total_count_num").text(data["total_count"]);
				$("#page_count_num").text(data["page_count"]);
				$("#page_count").val(data["page_count"]);
				$("#pageNumber a").remove();
				var html = '';
				
				$(".table-class tbody").empty();
				
				for(var i = 0; i < data["data"].length; i++){
					var item = data["data"][i];
					html += '<tr align="center">';
					if(item["is_system"] == 0){
						html += '<td><i class="checkbox-common"><input name="sub" type="checkbox" value="'+ item["routeid"] +'"></i></td>';
					}else{
						html += '<td><i class="checkbox-common disabled"><input name="sub" type="checkbox" value="'+ item["routeid"] +'" disabled></i></td>';
					}
					html += '<td style="text-align: left;">'+ item["rule"] +'</td>';
					html += '<td style="text-align: left;">'+ item["route"] +'</td>';
				
					switch(item["route_model"]){
						case 1 :
						html += '<td>shop</td>';
						break;
						case 2 :
						html += '<td>wap</td>';
						break;
						case 3 :
						html += '<td>admin</td>';
						break;
					}
					
					html += '<td align="left">'+ item["remark"] +'</td>';
					if(item["is_open"] == 0){
						html += '<td><img src="ADMIN_IMG/un_checked.png" alt="" width="15"/></td>';
					}else{
						html += '<td><img src="ADMIN_IMG/checked.png" alt="" width="15"/></td>';
					}
					if(item["is_system"] == 0){PLATFORM_MAIN/config
						html += '<td style="text-align:center;"><a href="'+__URL(PLATFORMMAIN+"/config/updateRoutingRule?routeid="+item["routeid"])+'">修改</a> <a href="javascript:;" onclick="delete_url_route('+item["routeid"]+');">删除</a></td>';
					}else{
						html += '<td style="text-align:center;"><a href="'+__URL(PLATFORMMAIN+"/config/updateRoutingRule?routeid="+item["routeid"])+'">修改</a></td>';
					}
					
					$(".table-class tbody").append(html);
					}
				} else {
					var html = '<tr align="center"><td colspan="9">暂无符合条件的数据记录</td></tr>';
				}
					
				$("#list").html(html);
				var totalpage = $("#page_count").val();
				if (totalpage == 1) {
					changeClass("all");
				}
				var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
				$("#pageNumber").append($html);
				$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
				}
		});
	}	

//删除
function delete_url_route(routeid){
	$( "#dialog" ).dialog({
		buttons: {
			"确定": function() {
				$(this).dialog('close');
				$.ajax({
					type : "post",
					url : "{:__URL('PLATFORM_MAIN/config/delete_url_route')}",
					data : { "routeid" : routeid.toString() },
					success : function(data) {
						if (data["code"] > 0) {
							showTip(data["message"],'success');
							location.href = "{:__URL('PLATFORM_MAIN/config/customPseudoStaticRule')}";
						}else{
							showTip(data["message"],'error');
						}
					}
				})
			},
			"取消,#f5f5f5,#666": function() {
				$(this).dialog('close');
			}
		},
	contentText:"是否删除该路由规则？",
	});
}


//批量删除
function batchDelete() {
	var routeid= new Array();
	$(".table-striped tbody input[type='checkbox']:checked").each(function() {
		if (!isNaN($(this).val())) {
			routeid.push($(this).val());
		}
	});
	if(routeid.length ==0){
		$( "#dialog" ).dialog({
			buttons: {
				"确定,#0059d6,#fff": function() {
					$(this).dialog('close');
				}
			},
			contentText:"请选择需要操作的记录",
			title:"消息提醒",
		});
		return false;
	}
	delete_url_route(routeid);
}
</script>
{/block}